namespace CSharpPro._1023;

public class Student
{
    // 私有字段
    private string _name;
    private int _age;
    private string _studentId;
    private string _major;
    private double _score;

    // 构造函数
    public Student(string name, int age, string studentId, string major)
    {
        _name = name;
        _age = age;
        _studentId = studentId;
        _major = major;
        _score = 0; // 初始成绩为0
    }

    // 显示学生信息
    public void ShowInfo()
    {
        Console.WriteLine($"学生信息：");
        Console.WriteLine($"姓名：{_name}");
        Console.WriteLine($"年龄：{_age}");
        Console.WriteLine($"学号：{_studentId}");
        Console.WriteLine($"专业：{_major}");
        Console.WriteLine($"当前成绩：{_score}");
    }

    // 学生学习行为
    public void Study(string course)
    {
        Console.WriteLine($"{_name}正在学习《{course}》");
    }

    // 学生考试行为（更新成绩）
    public void TakeExam(double score)
    {
        if (score >= 0 && score <= 100)
        {
            _score = score;
            Console.WriteLine($"{_name}参加考试，成绩为：{_score}");
        }
        else
        {
            Console.WriteLine("成绩无效，必须在0-100之间");
        }
    }

    // 属性访问器
    public string Name => _name;
    public int Age => _age;
    public string StudentId => _studentId;
    public string Major => _major;
    public double Score => _score;
}
